﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using Utilities.QuickSql;
using MySql.Data;

namespace Deviseur_Cs2i_Car
{
    public partial class AdminHTDI : Form
    {

        public AdminHTDI()
        {
            InitializeComponent();

            Thread HTDIThread = new Thread(new ThreadStart(getAllHTDI_Thread));
            HTDIThread.Start();
        }

        private void getAllHTDI_Thread()
        {
            Invoke(new MethodInvoker(getAllHTDI));
        }

        private void getAllHTDI()
        {
            Table HTDIVoiture = Program.Db.QueryTable("SELECT * FROM HTDI");

            this.dataHTDI.Rows.Clear();

            foreach (Record r in HTDIVoiture)
                this.dataHTDI.Rows.Add(r.Values[0], r.Values[1]);
        }

        private void AdminHTDI_Activated(object sender, EventArgs e)
        {
            Thread HTDIThread = new Thread(new ThreadStart(getAllHTDI_Thread));
            HTDIThread.Start();
        }

        private void buttonAddHTDI_Click(object sender, EventArgs e)
        {
            AddHTDI FenAddHTDI = new AddHTDI();
            FenAddHTDI.ShowDialog();
        }

        private void buttonDelHTDI_Click(object sender, EventArgs e)
        {
            HTDI delHTDI = new HTDI();
            delHTDI.delete_HTDI(Convert.ToInt32(this.dataHTDI.SelectedRows[0].Cells[0].Value.ToString()));
            Thread TypeThread = new Thread(new ThreadStart(getAllHTDI_Thread));
            TypeThread.Start();
        }

        private void ModifHTDI_Click(object sender, EventArgs e)
        {
            AddHTDI FenAddHTDI = new AddHTDI(Convert.ToInt32(this.dataHTDI.SelectedRows[0].Cells[0].Value.ToString()));
            FenAddHTDI.ShowDialog();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            AddHTDI FenAddHTDI = new AddHTDI();
            FenAddHTDI.ShowDialog();
        }




    }
}
